<template>
  <div>
    <van-nav-bar title="个人信息页" fixed placeholder left-arrow  @click-left="onClickLeft"/>
    <van-cell title="头像" is-link />
    <!-- <van-cell title="账号" is-link :value="userInfo.phone" /> -->
    <van-cell title="姓名" is-link :value="userInfo.nickName" to="/changeInfo"/>
    <van-cell title="性别" is-link :value="userInfo.sex===1?'男':'女'" to="/changeInfo"/>

    <!-- <van-cell title="手机" is-link :value="userInfo.phone" />
    <van-cell title="邮箱" is-link value="未填写" /> -->
    <div class="m-top">
      <van-cell title="地址管理" is-link to="/address"/>
    </div>
    <!-- <div class="m-top">
       <van-cell title="修改密码" is-link  />
       <van-cell title="绑定其他账号" is-link  />
    </div> -->
    <div class="m-top">
      <p @click="quit">退出当前账号</p>
    </div>
   

  </div>
</template>

<script>
import { getUserInfoApi } from "@/utils/api";
// import { mapState } from "vuex";
export default {
  data() {
    return {
      userInfo: {}
    };
  },

  components: {},

  created() {
    this.getUser();
  },

  methods: {
    // 退出登录页
    quit() {
      localStorage.clear();
      // this.$store.commit("quitUser");
      // this.$router.replace("/home/mine");
      this.$router.go(-1);
    },
    // 获得用户信息
    getUser() {
      getUserInfoApi({ token: localStorage.getItem("token") }).then(res => {
        if (res.status === "0") {
          console.log(res);
          this.userInfo = res.result;
        }
      });
    },
    onClickLeft() {
      this.$router.go(-1);
    }
  }
};
</script>

<style lang="less" scoped>
.m-top {
  margin-top: 10px;
  p {
    height: 44px;
    line-height: 44px;
    font-size: 16px;
    text-align: center;
    background-color: #fff;
  }
}
</style>
